<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title>经纪人验证</title>
		<meta content="width=device-width,initial-scale=1.0,maximum-scale=1.0,user-scalable=0" name="viewport" />
		<meta content="yes" name="apple-mobile-web-app-capable" />
		<meta content="black" name="apple-mobile-web-app-status-bar-style" />
		<meta content="telephone=no" name="format-detection" />
		<!-- 引入YDUI样式 -->
		<link rel="stylesheet" href="../build/css/ydui.css" />
		<link rel="stylesheet" href="../css/common.css" />
		<link rel="stylesheet" href="../css/fontcss/css/font-awesome.min.css" />
		<link rel="stylesheet" href="../css/upload/bootstrap-fileinput.css" />
		<link rel="stylesheet" href="../css/upload/bootstrap.min.css" />
		<!-- <link rel="stylesheet" href="../css/upload/index.css" /> -->
		<!-- 引入YDUI自适应解决方案类库 -->
		<script src="../build/js/ydui.flexible.js"></script>
		<script src="../js/jq331.min.js"></script>
		<script src="../js/common.js"></script>
		<!-- 引入YDUI脚本 -->
		<script src="../build/js/ydui.js"></script>
		<script src="../js/upload/bootstrap-fileinput.js"></script>
		<style>
			.page-header{
				margin: 0;
				border-bottom: 0;
			}
			.fileinput,.form-group{
				margin-bottom: 0;
			}
			label{
				font-size: 12px;
				display: inline-block;
				min-width: 1.9rem;
				text-align: right;
				color:#666666;
				font-weight: normal;
				margin-bottom: 0;
			}
			input{
				font-size: 12px;
			/* 	font-family: -webkit-pictograph; */
				border:1px solid #eee;
				padding: .1rem .3rem;
				color:#666666;
				}
			.basicinfo{padding: .2rem;}
			.basicinfo div{			
				padding: .25rem .2rem;
				align-items: center;
			}
			.modifywd{
				margin-left: .1rem;
				padding: .1rem .2rem;
				 border: 1px solid #eee; 
				border-radius: .1rem;
				color: #ffffff;
				background: #C1060F;
			}
			#uploadbotton{
				font-size: .5rem;
				padding: .3rem;
				border: #B8B8B8 dashed 1px;
			}
			#submitClick{
				display: list-item;
				border: none;
				color: #fff;
				background: #C1060F;
				padding: .15rem 2rem;
				border-radius: .1rem;
				margin: 0 auto;
			}
			#tips{
				padding: .2rem;
				color: #868686;
			}
			#tips p{
				color:#C1060F;
				padding: .1rem 0;
			}
			#tips .desc{
				font-size: 13px;
				text-indent: 2em;
				line-height: .4rem;
			}
			.require{
				color:red;
			}
			.thumbnail{
				border: 1px dashed #ddd;
			}
			.appendimg{
				position:absolute;width:1.5rem; top:1.5rem;right:.5rem;
			}
			.unsubmit{
				background: #ccc !important;
			}
		</style>
	</head>
	<body>
		
		<div class="logincantion" >
			<header class="m-navbar">
				<a href="#" onClick="javascript :window.history.back(); return false;" class="navbar-item">
					<i class="back-ico"></i>
				</a>
				<div class="navbar-center">
					<span class="navbar-title">经纪人验证</span>
				</div>
			</header>
			<div class="basicinfo">
				<img class="appendimg" / > <!-- 审核状态图标 -->
				<div class="page-header">
					<form method="post" enctype='multipart/form-data'>
						<div>
							<label>姓名<a class="require">&nbsp;*&nbsp;&nbsp;</a></label>
							<input type="text"  placeholder="请输入身份证姓名" value="" name="name"/>
						</div>
						<div>
							<label>手机号<a class="require">&nbsp;*&nbsp;&nbsp;</a></label>
							<input type="number" pattern="[0-9]*"  placeholder="请输入手机号码" value="" name="tel" autocomplete="off" />
						</div>
						<div>
							<label>身份证号码<a class="require">&nbsp;*&nbsp;&nbsp;</a></label>
							<input type="text" placeholder="输入有效身份证号码"  value="" name="idcard"/>
						</div>					
						<div class="form-group" id="uploadForm" > 
							<div class="fileinput fileinput-new" data-provides="fileinput"  id="exampleInputUpload">
								<div class="fileinput-new thumbnail" style="width: 200px;height: auto;max-height:165px;">
									<img id='picImg' style="width: 100%;height: auto;max-height: 140px;" src="../static/images/noimage.png" alt="" />
								</div>
								<div class="fileinput-preview fileinput-exists thumbnail" style="max-width: 200px; max-height: 165px;"></div>
								<div>
									<span class="btn btn-primary btn-file">
										<span class="fileinput-new" style="font-size: 12px;"><a style="color:#fff">&nbsp;*&nbsp;&nbsp;</a>上传身份证照片(正面)</span>
										<span class="fileinput-exists">换一张</span>
										<input type="file" name="pic1" id="picID" accept="image/gif,image/jpeg,image/x-png"/>
									</span>
									<a href="javascript:;" class="btn btn-warning fileinput-exists" data-dismiss="fileinput">移除</a>
								</div>
							</div>
						</div>
						<button  type="button" id="submitClick" class="font-sty">提交审核验证</button>
					</form>				 
				</div>								
			</div>
			<!-- 温馨提示 -->
			<div id="tips">
				<p>*温馨提示</p>
				<div class='desc'>
					和房宝是一款面向全民大众提供真实有效的房源app平台，请务必提供真实有效验证资料，否则会影响您的房源信息发布
				</div>
			</div>
		</div>
		
		<!-- 回到首页 -->
		<a href="../index.html">
			<div id="preparation"><i style="font-size: .4rem;" class='fa fa-home'></i></div>
		</a>
	</body>
	<script>
		$(document).ready(function(){
			var checkingApi = commapi + "yanzheng/yanzheng"; 
			var getstatusApi = commapi + "yanzheng/shenhe";
			 $('#submitClick').click(function () {
				 var name = $("input[name='name']").val();
				 var tel = $("input[name='tel']").val();
				 var idcode = $("input[name='idcard']").val();
				 var data = new FormData($('#uploadForm')[0]);			 
				 var form = new FormData();
				  form.append("image",$('#picID')[0].files[0]);
				  form.append("card_name",name);
				  form.append("card_phone",tel);
				  form.append("card_number",idcode);
				  //console.log($('#picID')[0].files[0])
				  if(name =='' || tel =='' || idcode =='' || $('#picID')[0].files[0] ==null){
					  	!function (win, $) {
					  		var dialog = win.YDUI.dialog;						
					  			dialog.toast('带 * 为必填字段', 'error', 2000);
					  			setTimeout(function () {
					  				dialog.loading.close();/* 移除loading */
					  			}, 2000);					  	
							}(window, jQuery);					
				  }else{
					 $.ajax({
					 	url: checkingApi,
					 	type: 'POST',
					 	data: form,             
					 	cache: false,
					 	contentType: false,
					 	processData: false,
					 	beforeSend: function(request) {
					 			request.setRequestHeader("token", dataToken);
					 			},
					 	success: function (data) {
							console.log(data)
							if(data.msg=="上传认证信息成功"){
								!function (win, $) {
									var dialog = win.YDUI.dialog;						
										dialog.toast('提交成功', 'success', 2000);
										setTimeout(function () {
											dialog.loading.close();/* 移除loading */
										}, 2000);							
								}(window, jQuery);	
								$('.appendimg').attr('src','../static/images/checking.png');
								window.location.reload()
							}else{
								console.log('00')
								YDUI.dialog.toast(data.msg, 'none', 2000);
							}						
					 	},              
					 }); 
				  }       
			});
			
			//获取验证资料
			$.ajax({
			url: getstatusApi,
			type: 'POST',
			data: {},             			
			beforeSend: function(request) {
					request.setRequestHeader("token", dataToken);
					},
			success: function (data) {
						console.log(data)
						if(data.is_submit == 1){ //已经提交的状态下获取验证资料信息
								if(data.is_examine == 0){ //审核中不给再次提交
									$('.appendimg').attr('src','../static/images/checking.png');
									$("input[name='name']").attr('readonly','readonly');
									$("input[name='tel']").attr('readonly','readonly');
									$("input[name='idcard']").attr('readonly','readonly');							
									$('#submitClick').attr('disabled','disabled');
									$('#submitClick').addClass('unsubmit');								
								}else if(data.is_examine == 1){ //审核通过 不给再次提交
									$('.appendimg').attr('src','../static/images/pass.png');							
									$("input[name='name']").attr('readonly','readonly');
									$("input[name='tel']").attr('readonly','readonly');
									$("input[name='idcard']").attr('readonly','readonly');
									$('#submitClick').addClass('unsubmit');
									$('#submitClick').attr('disabled','disabled');																		
								}else{ //审核不通过
									$('.appendimg').attr('src','../static/images/unpass.png');
									$('#submitClick').html('重新提交审核');
								};							
							$("input[name='name']").val(data.card_name);
							$("input[name='tel']").val(data.card_phone);
							$("input[name='idcard']").val(data.card_number);						
							$('#picImg').attr('src',commimgurl + data.card_img)						
						}			
					},              
			}); 
			
		});
	</script>
	<!-- 引入YDUI脚本 -->
	<script src="../build/js/ydui.flexible.js"></script>
	<script src="../build/js/ydui.js"></script>
</html>
